package cn.congzhou.crm.domain;

import cn.congzhou.crm.utils.DateUtil;
import com.alibaba.fastjson.JSON;
import lombok.*;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Getter@Setter@ToString
@AllArgsConstructor
@NoArgsConstructor
public class CustomerTraceHistory {
    private Long id;

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date traceTime;//跟进时间

    private String traceDetails;//跟进明细，备注

    private SystemDictionaryItem traceType;//跟进方式

    private Integer traceResult;//跟进结果

    private String remark;//跟进记录

    private Customer customer;//客户姓名

    private Employee inputUser;//录入人

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date inputTime;//录入时间

    public String getTraceResultName(){
        if(traceResult==1){
            return "优";
        }else if(traceResult==2){
            return "中";
        }else {
            return "差";
        }
    }

    //返回JSON对象
    public String getJson(){
        Map<String, Object> map = new HashMap<>();
        map.put("id",id);
        map.put("customerName",customer.getName());
        String traceDate = DateUtil.formatDate(traceTime);
        map.put("traceTime",traceDate);
        map.put("traceDetails",traceDetails);
        map.put("remark",remark);
        map.put("traceTypeId",traceType.getId());
        map.put("traceResult",traceResult);
        return JSON.toJSONString(map);
    }


}